#ifndef _AutoOutput_LOG_H_
#define _AutoOutput_LOG_H_
#include <stdio.h>
#include "phlogger.h"
#include "get_thread_id.h"

class CAutoOutput
{
public:
	CAutoOutput(const char *szIn, const char * szOut, LOG_FLAG flag = LOG_ANOLE)
		:m_szIn(szIn)
		,m_szOut(szOut)
		,m_flag(flag)
	{
		WriteLog(m_flag,m_szIn.c_str());
	}
	~CAutoOutput()
	{
		WriteLog(m_flag,m_szOut.c_str());
	}
	LOG_FLAG m_flag;
    std::string m_szIn;
	std::string m_szOut;
};

class CAutoOutput2
{
public:
    CAutoOutput2(const char *szfunction, const char * szfile, int line)
        :m_szfunction(szfunction)
        ,m_flag(LOG_INFO)
    {
        WriteLog(LOG_INFO, ">>> [debug][%ld] call %s at [%s:%d].", gettid2(), m_szfunction.c_str(), szfile, line);
    }
    ~CAutoOutput2()
    {
        WriteLog(LOG_INFO, "<<< [debug][%ld] %s end.", gettid2(), m_szfunction.c_str());
    }
    LOG_FLAG m_flag;
    std::string m_szfunction;
};

#define DEBUG_INFO      WriteLog(LOG_INFO, "[debug] call %s at [%s:%d]", __FUNCTION__, __FILE__, __LINE__)
#define DEBUG_TINFO     WriteLog(LOG_INFO, "[debug][%lu] call %s at [%s:%d]", gettid2(), __FUNCTION__, __FILE__, __LINE__)

#endif //_AutoOutput_LOG_H_

